<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
  function test1(){
	  $.ajax({
          type: "POST",
          url: "${pageContext.request.contextPath}/elecStatus/updateData.action",
          data: {username:'1', content:'2'},
          dataType: "json",
          success: function(data){
         	 var tbody = "";
              $("#result").html("------------遍历对象 .each的使用-------------");
              //下面使用each进行遍历
              $.each(data.person, function (n, value) {
                  tbody = tbody + "<tr><td>" + value['name']+":"+value['sex']+"</td></tr>";
                  alert(tbody);
              });
              $("#tab").append(tbody);
    
              }
      });
  }


	function test() {

		 var d2='{"data":"1799","id":1,"name":"设备1-A","status":"开启"}';
		var eq=JSON.parse(d2);
		alert(eq.data);
	
		var d1=JSON.stringify(eq); 
	     alert(1)
		$.ajax({
					type : 'post',
					url : '${pageContext.request.contextPath}/elecStatus/updateData.action',
					dataType : 'json',
					data : {username:d2, content:'2'},
					success : function(dat) {

					}
				}) 
	}

	
</script>
<script type="text/javascript" src="js/json2.js"></script> 
<script type="text/JavaScript">
function parse(){
	//把json 字符串转换成对象
	 var string = '{"name":"frank", "age":29, "birthday":"1978-1-1"}';
	 var user = JSON.parse(string);
	 alert(user.name);
	 alert(user.age);
	 alert(user.birthday);
	 //把对象转换成json字符串
	 alert (JSON.stringify(user))
}
 

</script>



</head>
<body>
	<button onclick="test()">test</button>
</body>
</html>